package com.aat.dxfy.web.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map.Entry;
import java.util.TreeMap;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;

import com.aat.dxfy.web.utils.WebConstant;

@WebServlet("/get.do")
public class ThisServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public ThisServlet() {
		super();
	}

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int a = WebConstant.USERNUM;
		System.out.println("online user :" + a);
		TreeMap<String, Object> UserMap = WebConstant.UserMap;
		for (Entry<String, Object> entry : UserMap.entrySet()) {
			System.out.println(entry.getKey() + "  " + entry.getValue());
		}

		PrintWriter out = response.getWriter();
		JSONObject json = new JSONObject();
		json.put("num", a);
		json.put("b", WebConstant.UserMap);
		out.println(json.toJSONString());
		out.flush();
		out.close();
	}

}
